import { S } from '../../s';
import { IPSControlAttribute } from '../ipscontrol-attribute';
import { IPSControlLogic } from '../ipscontrol-logic';
import { IPSControlRender } from '../ipscontrol-render';
import { IPSDEGridColumn } from './ipsdegrid-column';
import { IPSLanguageRes } from '../../res/ipslanguage-res';
import { IPSSysCss } from '../../res/ipssys-css';
import { IPSSysImage } from '../../res/ipssys-image';
import { IPSSysPFPlugin } from '../../res/ipssys-pfplugin';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEGridColumnImpl
  extends PSModelObjectImpl
  implements IPSDEGridColumn
{
  get aggField(): string {
    return this.M.aggField;
  }

  get aggMode():
    | 'NONE'
    | 'SUM'
    | 'AVG'
    | 'MAX'
    | 'MIN'
    | 'USER'
    | 'USER2'
    | 'USER3'
    | 'USER4' {
    return this.M.aggMode || 'NONE';
  }

  get aggValueFormat(): string {
    return this.M.aggValueFormat;
  }

  get align(): 'LEFT' | 'CENTER' | 'RIGHT' {
    return this.M.align;
  }

  protected cappslanguageres: IPSLanguageRes;
  getCapPSLanguageRes(): IPSLanguageRes | null {
    return (
      this.cappslanguageres ||
      (this.cappslanguageres = this.fillObjectModel(
        S._276,
        this.M.getCapPSLanguageRes,
        S._2a8,
      ) as IPSLanguageRes)
    );
  }

  get caption(): string {
    return this.M.caption;
  }

  protected cellpssyscss: IPSSysCss;
  getCellPSSysCss(): IPSSysCss | null {
    return (
      this.cellpssyscss ||
      (this.cellpssyscss = this.fillObjectModel(
        S._278,
        this.M.getCellPSSysCss,
        S._2f5,
      ) as IPSSysCss)
    );
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get columnStyle(): string {
    return this.M.columnStyle;
  }

  get columnType(): 'DEFGRIDCOLUMN' | 'UAGRIDCOLUMN' | 'GROUPGRIDCOLUMN' {
    return this.M.columnType;
  }

  get dataItemName(): string {
    return this.M.dataItemName;
  }

  get excelCaption(): string {
    return this.M.excelCaption;
  }

  protected headerpssyscss: IPSSysCss;
  getHeaderPSSysCss(): IPSSysCss | null {
    return (
      this.headerpssyscss ||
      (this.headerpssyscss = this.fillObjectModel(
        S._278,
        this.M.getHeaderPSSysCss,
        S._2f6,
      ) as IPSSysCss)
    );
  }

  get noPrivDisplayMode(): 1 | 2 {
    return this.M.noPrivDisplayMode;
  }

  protected pscontrolattributes: IPSControlAttribute[];
  getPSControlAttributes(): IPSControlAttribute[] | null {
    return (
      this.pscontrolattributes ||
      (this.pscontrolattributes = this.fillChildListModel(
        this.M.getPSControlAttributes,
        S._3f5,
      ) as IPSControlAttribute[])
    );
  }

  findPSControlAttribute(objKey: any): IPSControlAttribute | null {
    return this.getPSModel5(
      S._3f5,
      this.getPSControlAttributes(),
      objKey,
    ) as IPSControlAttribute;
  }

  protected pscontrollogics: IPSControlLogic[];
  getPSControlLogics(): IPSControlLogic[] | null {
    return (
      this.pscontrollogics ||
      (this.pscontrollogics = this.fillChildListModel(
        this.M.getPSControlLogics,
        S._38d,
      ) as IPSControlLogic[])
    );
  }

  findPSControlLogic(objKey: any): IPSControlLogic | null {
    return this.getPSModel5(
      S._38d,
      this.getPSControlLogics(),
      objKey,
    ) as IPSControlLogic;
  }

  protected pscontrolrenders: IPSControlRender[];
  getPSControlRenders(): IPSControlRender[] | null {
    return (
      this.pscontrolrenders ||
      (this.pscontrolrenders = this.fillChildListModel(
        this.M.getPSControlRenders,
        S._3f6,
      ) as IPSControlRender[])
    );
  }

  findPSControlRender(objKey: any): IPSControlRender | null {
    return this.getPSModel5(
      S._3f6,
      this.getPSControlRenders(),
      objKey,
    ) as IPSControlRender;
  }

  protected pssysimage: IPSSysImage;
  getPSSysImage(): IPSSysImage | null {
    return (
      this.pssysimage ||
      (this.pssysimage = this.fillObjectModel(
        S._27b,
        this.M.getPSSysImage,
        S._2ad,
      ) as IPSSysImage)
    );
  }

  protected renderpssyspfplugin: IPSSysPFPlugin;
  getPSSysPFPlugin(): IPSSysPFPlugin | null {
    return (
      this.renderpssyspfplugin ||
      (this.renderpssyspfplugin = this.fillObjectModel(
        S._27c,
        this.M.getPSSysPFPlugin,
        S._2a7,
      ) as IPSSysPFPlugin)
    );
  }

  get width(): number {
    return this.M.width;
  }

  get widthUnit(): 'PX' | 'STAR' {
    return this.M.widthUnit;
  }

  get enableRowEdit(): boolean {
    return this.M.enableRowEdit != null ? this.M.enableRowEdit : false;
  }

  get enableSort(): boolean {
    return this.M.enableSort;
  }

  get hiddenDataItem(): boolean {
    return this.M.hiddenDataItem != null ? this.M.hiddenDataItem : false;
  }

  get hideDefault(): boolean {
    return this.M.hideDefault != null ? this.M.hideDefault : false;
  }
  get cls(): string {
    return 'PSDEGridColumnImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._3f7 || cls == S._c6) return true;
    return super.instanceof(cls);
  }
}
